package ningbo.collection;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

/**
 * @Author 宁铂
 * @Date 2021/7/27 22:24
 * @Version 1.0
 */
public class TestList2 {
    /** 进一步测试List接口 */
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("100");
        list.add("200");
        list.add("300");
        list.add("400");
        list.add("500");
        list.add("600");
        System.out.println(list);

        /** 集合的集合
         *  集合的迭代方法:
         *  for
         *  高效for
         *  iterator
         *  listIterator
         * */

        for (int i = 0; i <= list.size()-1; i++)
            System.out.print(list.get(i)+" ");

        System.out.println("");

        for (String s : list) {
            System.out.print(s+" ");
        }

        System.out.println("");

        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext())
            System.out.print(iterator.next()+" ");

        System.out.println("");

        ListIterator<String> stringListIterator = list.listIterator();
        while (stringListIterator.hasNext())
            System.out.print(stringListIterator.next()+" ");
    }
}
